﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace StringEM
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void 转换_Click(object sender, EventArgs e)
        {
            string str_ok = "";
            string st = textBox1.Text; 
            string[] stArr = st.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if(stArr.Length == 0)
            {
                MessageBox.Show("待转化文本不能为空！");
            }
            foreach(string i in stArr)
            {
                string i_ok;
                string[] iArr = i.Split(new string[] { "----" }, StringSplitOptions.RemoveEmptyEntries);
                //百度云账号: jiao49521451tuhu8@163.com百度云密码:jfkgp47526 密保邮箱账号:jiao49521451tuhu8@163.com密保邮箱密码:na14042
                i_ok = "百度云账号:" + iArr[0] +  "百度云密码:" + iArr[1] + " " + "密保邮箱账号:" + iArr[2] + "密保邮箱密码:" + iArr[3] + "\r\n";
                str_ok = str_ok + i_ok;
            }


            textBox2.Text = str_ok;
            //string tc = st.Split(new string[] { "----" }, StringSplitOptions.RemoveEmptyEntries);

        }

        private void 保存_Click(object sender, EventArgs e)
        {
            saveFileDialog1.Filter = "文本文件|*.txt";
            if(saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                StreamWriter FileWriter = new StreamWriter(saveFileDialog1.FileName, true); //写文件

                FileWriter.Write(textBox2.Text);//将字符串写入
                FileWriter.Close(); //关闭StreamWriter对象
                MessageBox.Show("文件保存成功！");
            }
        }
    }
}
